﻿//创建时间: 2010-10-11
//创建作者: 李 城
//功能说明: 内容模型 字段管理
//最后修改: 2010-10-11
//最后修改: 2010-10-21李晓忠  增加GetWithTableNameListByCondition功能
//最后修改: 2010-11-16李晓忠  增加获取标题字段功能
//最后修改: 2010-11-19 李晓忠  添加获取主内容字段
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Reflection;

using TRPOP.Common;
using TRPOP.CMS.Model;

namespace TRPOP.CMS.DALFactory
{
    public interface IModelFieldDAL
    {

        ///	<summary>
        ///	保存
        ///	</summary>
        ///	<param name="ModelFieldInfo"></param>
        ///	<returns>EnumSubmitResult</returns>
        EnumSubmitResult Save(ModelFieldInfo info);

        ///	<summary>
        ///	获取实体
        ///	</summary>
        ///	<param name="modelFieldId"></param>
        ///	<returns>ModelFieldInfo</returns>
        ModelFieldInfo GetInfoById(int id);

        ///	<summary>
        ///	删除
        ///	</summary>
        ///	<param name="id"></param>
        ///	<returns>EnumSubmitResult</returns>
        EnumSubmitResult DeleteInfoById(int id);

        ///	<summary>
        ///	删除
        ///	</summary>
        ///	<param name="ids"></param>
        ///	<returns>EnumSubmitResult</returns>
        EnumSubmitResult DeleteInfoByIds(string ids);

        ///	<summary>
        ///	自定义列表（无分页）
        ///	</summary>
        ///	<param name="topn">前N条，为0时表示所有符合条件的</param>
        ///	<param name="condition">自定义条件，要以And开头</param>
        ///	<param name="orderby">排序，不需要Order by </param>
        ///	<returns>List<ModelFieldInfo></returns>
        List<ModelFieldInfo> GetListByCondition(int topn, string condition, string orderby);

        ///	<summary>
        ///	自定义列表（分页）
        ///	</summary>
        ///	<returns>List<ModelFieldInfo></returns>
        List<ModelFieldInfo> GetListByPager(int pageNumber, int pageSize, string condition, string orderby, out int recordCount);
     
        /// <summary>
        /// 通过ModelId 获取模型字段 GetWithTableNameListByModelId
        /// </summary>
        /// <param name="topn"></param>
        /// <param name="condition"></param>
        /// <param name="orderby"></param>
        /// <returns></returns>
        List<ModelFieldInfoWithTableName> GetWithTableNameListByModelId(int ModelId);
        /// <summary>
        ///   通过NodeId 获取模型字段 GetWithTableNameListByNodeId
        /// </summary>
        /// <param name="NodeId"></param>
        /// <returns></returns>
        List<ModelFieldInfoWithTableName> GetWithTableNameListByNodeId(int NodeId);

        /// <summary>
        /// 模型 列表显示字段列表 GetTableFieldListDisplayListByNodeId
        /// </summary>
        /// <param name="NodeId"></param>
        /// <returns></returns>
        List<ModelFieldInfo> GetTableFieldListDisplayListByNodeId(int NodeId);
        /// <summary>
        /// 获取标题字段
        /// </summary>
        /// <param name="NodeId"></param>
        /// <returns></returns>
        ModelFieldInfo GetTableTitleFieldByNodeId(int NodeId);
        /// <summary>
        /// 获取标题字段
        /// </summary>
        /// <param name="ModelId"></param>
        /// <returns></returns>
        ModelFieldInfo GetTableTitleFieldByModelId(int ModelId);
        /// <summary>
        /// 获取主内容字段
        /// </summary>
        /// <param name="NodeId"></param>
        /// <returns></returns>
        ModelFieldInfo GetTableMainFieldByNodeId(int NodeId);

        /// <summary>
        /// 获取主内容字段
        /// </summary>
        /// <param name="ModelId"></param>
        /// <returns></returns>
        ModelFieldInfo GetTableMainFieldByModelId(int ModelId);

        /// <summary>
        /// 更新标题字段
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        EnumSubmitResult UpdateTitleFiled(int id);
        
        /// <summary>
        /// 更新主内容字段
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        EnumSubmitResult UpdateMainField(int id);

        /// <summary>
        /// 将字段更新到相反的值 1==0 0==1
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        EnumSubmitResult UpdateField(int id, string type);
        /// <summary>
        /// 获取搜索字段
        /// </summary>
        /// <param name="NodeId"></param>
        /// <returns></returns>
        List<ModelFieldInfo> GetTableSearchFieldListByNodeId(int NodeId);

    }


    public sealed partial class DataAccess
    {
        public static IModelFieldDAL CreateModelFieldDAL()
        {
            string className = path + ".ModelFieldDAL";
            return (IModelFieldDAL)Assembly.Load(path).CreateInstance(className);
        }
    }
}
